home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
byt1186b.arc
/
DRAGON.DOC
< prev
next >
Wrap
Text File
|
2018-07-12
|
3KB
|
67 lines
Screen #1
( begin Dragon curve )
CREATE CURVE ( a FORGETable name)
CARTESIAN OFF
: RECURS SMUDGE ; IMMEDIATE ( trick verb for recursion)
VARIABLE ANGLE
VARIABLE XCOOD
VARIABLE YCOOD
VARIABLE STEPSIZE
: TURN ( deltangle-- | turn sign*delta)
ANGLE +! ;
2 4 THRU
Screen #2
: MOVE ( -- | takes a step in present turtle direction)
STEPSIZE @ DUP
ANGLE @ COS * 10000 / ( r* cos of theta) XCOOD @ +
DUP ( newX) XCOOD ! ( update X)
SWAP
ANGLE @ SIN * 10000 / ( r* sine theta ) YCOOD @ +
DUP ( newY) YCOOD ! ( update Y)
DRAW.TO ;
Screen #3
: DRAGON ( sign level-- | )
DUP ( level) 0=
IF ( at bottom of recursion)
DROP ( level) DROP ( sign) MOVE ( by stepsize)
ELSE
OVER 45 * TURN ( getsign and turn)
1 ( newsign)
OVER 1- ( level=level-1)
RECURS DRAGON RECURS
OVER -90 * TURN ( getsign & turn)
-1 ( newsign) ( edit to +1 for diff curve)
OVER 1- ( level=level-1)
RECURS DRAGON RECURS
DROP ( input level) 45 * TURN ( getsign and turn)
THEN ;
Screen #4
: DCURVE ( level --| )
( init pen position)
PAGE 100 XCOOD ! 90 YCOOD ! 360 6 * ANGLE !
WHITE PENPAT XCOOD @ YCOOD @ MOVE.TO
PEN.NORMAL
1 STEPSIZE !
1 SWAP ( level) DRAGON
WHITE PENPAT 4 10 MOVE.TO PEN.NORMAL ;